'use strict';

// 引入第三方包
import Vue from 'vue';

//VueRouter:引入路由对象
import VueRouter from 'vue-router';

Vue.use(VueRouter);

//Mint:引入mint-ui
import Mint from 'mint-ui';
//Mint:引入css
import 'mint-ui/lib/style.css';
//Mint:安装插件
Vue.use(Mint);
//MUI:引入mui的样式
import './static/vendor/mui/dist/css/mui.css';
//全局样式
import './static/css/global.css';

//引入 Axios
import Axios from 'axios';

Vue.prototype.$ajax = Axios;
// 默认设置
Axios.defaults.baseURL = 'http://localhost/tag/test/api.php?act=';
//Moment:引入moment
import Moment from 'moment';

Vue.prototype.$moment = Moment;
//引入第三方包 结束

// 定义成全局组件或过滤器，大家都能使用 开始
Vue.filter('convertDate', function (value) {
    return Moment(value).format("YYYY-MM-DD HH:mm")
});

//引入全局组件需要的组件对象 开始
import NavBar from './components/common/navBar.vue';
//引入全局组件需要的组件对象 开始
Vue.component('NavBar', NavBar); // 使用最好以 nav-bar

//定义全局组件或过滤器 结束

//引入自己的vue文件 开始
import App from './app.vue';
import Home from './components/home/home.vue';
import NewsList from './components/news/list.vue';
import NewDetail from './components/news/detail.vue';
import Member from './components/member/member.vue';
import ShopCart from './components/shopcart/shopcart.vue';
import Search from './components/search/search.vue';

//VueRouter:创建对象并配置路由规则！！！导航
let router = new VueRouter({
    linkActiveClass: 'mui-active', // 结合路由规则，如路由规则有同名的话，都会赋值
    //VueRouter：配置路由规则
    routes: [
        {path: '/', redirect: {name: 'home'}},
        {name: 'home', path: '/home', component: Home},
        {name: 'news.list', path: '/news/list', component: NewsList},
        {name: 'news.detail', path: '/news/detail', component: NewDetail},
        {name: 'member', path: '/member', component: Member},
        {name: 'shopcart', path: '/shopcart', component: ShopCart},
        {name: 'search', path: '/search', component: Search},

    ]
});

// 创建实例
new Vue({
    el: '#app',
    router,
    render: c => c(App)
});
